
export class ContentClient {

    constructor() {
        this.initEvents()
    }
    static init() {
        const client = new ContentClient()
        return client
    }
    private initEvents() {
        window.addEventListener('message',(event:MessageEvent) => {
            const {type,data} = event.data
            const func: any = Reflect.get(this, `_${type}`)
            if (func && typeof func === 'function') {
                func.call(this, data)
            }
        })

    }

    _installDogScript(url: string) {
        chrome.runtime.sendMessage({ type: 'installScript', data: url })
    }
}